﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Windows.Forms;
using System.Windows.Forms.Design;


namespace App
{
    public class CBList : CheckedListBox
    {

        public CBList()
        {
            this.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.CheckOnClick = true;
            this.ForeColor = Common.ForColor;
            this.MultiColumn = true;
        }

        public List<string> SelectedList
        {
            get
            {
                List<string> list = new List<string>();
                for (int i = 0; i < Items.Count; i++)
                {
                    if (GetItemChecked(i))
                    {
                        list.Add(GetItemText(Items[i]));
                    }
                }
                return list;
            }
        }

        public string SelectedText
        {
            get
            {
                string text = "";
                foreach(string str in SelectedList)
                {
                    text += " ";
                    text += str;
                }

                return text;
            }
        }

        public void SelectAll()
        {
            SelectAll(true);
        }

        public void SelectAll(bool selected)
        {
            for (int i = 0; i < Items.Count; i++)
            {
                SetItemChecked(i, selected);
            }
        }

       
    }

}
